<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios常用配置以及默认配置</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>
</head>
<body>
    <button>王者荣耀</button>
    <button>英雄联盟</button>
    <script>
        let btns = document.querySelectorAll('button');

        // 配置通用的基础地址
        axios.defaults.baseURL = 'http://api.xiaohigh.com'
        axios.defaults.timeout = 4000

        btns[0].onclick = async function(){
          axios('/heros')
        }

        btns[1].onclick = async function(){
          axios('/lol')
        }
    </script>
</body>
</html>